Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gnrc_netif: fix packet leak with gnrc_netif_pktq & netdev_new_api #20983

Open
wants to merge 3 commits into from

Conversation

benpicco
Copy link
Contributor

Contribution description

With netdev_new_api packets are not released on send anymore.
gnrc_netif_pktq adds a hold on a packet to not release it on send.

Even though 1 + 1 - 1 - 1 should be 0, we are leaking packets on send.

Testing procedure

Run a driver that makes use of both netdev_new_api and gnrc_netif_pktq (e.g. at86rf215):

master

2024-11-13 13:49:00,444 # ping -c 10 -s 1024 ff02::23%6
2024-11-13 13:49:08,446 # error: packet buffer full
2024-11-13 13:49:09,446 # error: packet buffer full
2024-11-13 13:49:10,443 # 
2024-11-13 13:49:10,446 # --- ff02::23%6 PING statistics ---
2024-11-13 13:49:10,452 # 10 packets transmitted, 0 packets received, 100% packet loss
pktbuf stats
2024-11-13 13:49:37,227 # packet buffer: first byte: 0x20001c28, last byte: 0x20002c28 (size: 4096)
2024-11-13 13:49:37,229 #   position of last byte used: 4072
2024-11-13 13:49:37,234 # =========== chunk   0 (0x20001c28 size: 1848) ===========
2024-11-13 13:49:37,242 # 00000000  00  00  00  00  40  1C  00  20  10  00  00  00  01  00  00  00
2024-11-13 13:49:37,247 # 00000010  00  55  55  55  55  55  55  55  01  02  66  19  E8  3F  8E  6B
2024-11-13 13:49:37,253 # 00000020  4C  E6  00  00  00  00  00  00  28  1C  00  20  68  1C  00  20
2024-11-13 13:49:37,260 # 00000030  08  00  00  00  01  00  00  00  03  55  55  55  55  55  55  55
2024-11-13 13:49:37,266 # 00000040  85  00  2A  CF  00  00  00  00  00  00  00  00  88  1C  00  20
2024-11-13 13:49:37,272 # 00000050  10  00  00  00  01  00  00  00  00  55  55  55  55  55  55  55
2024-11-13 13:49:37,279 # 00000060  01  02  66  19  E8  3F  8E  6B  4C  E7  00  00  00  00  00  00
2024-11-13 13:49:37,285 # 00000070  70  1C  00  20  F0  1C  00  20  08  00  00  00  01  00  00  00
2024-11-13 13:49:37,291 # 00000080  03  55  55  55  55  55  55  55  D0  1C  00  20  C8  1C  00  20
2024-11-13 13:49:37,298 # 00000090  08  00  00  00  01  00  00  00  FF  55  55  55  55  55  55  55
2024-11-13 13:49:37,304 # 000000A0  00  00  06  00  40  00  00  80  50  1C  00  20  E8  1C  00  20
2024-11-13 13:49:37,311 # 000000B0  04  00  00  00  01  00  00  00  01  55  55  55  55  55  55  55
2024-11-13 13:49:37,317 # 000000C0  7B  3B  3A  02  40  0F  00  00  85  00  2A  CD  00  00  00  00
2024-11-13 13:49:37,323 # 000000D0  00  00  00  00  10  1D  00  20  10  00  00  00  01  00  00  00
2024-11-13 13:49:37,330 # 000000E0  00  55  55  55  55  55  55  55  01  02  66  19  E8  3F  8E  6B
2024-11-13 13:49:37,336 # 000000F0  4C  E6  00  00  00  00  00  00  F8  1C  00  20  78  1D  00  20
2024-11-13 13:49:37,343 # 00000100  08  00  00  00  01  00  00  00  03  55  55  55  55  55  55  55
2024-11-13 13:49:37,349 # 00000110  58  1D  00  20  50  1D  00  20  08  00  00  00  01  00  00  00
2024-11-13 13:49:37,355 # 00000120  FF  55  55  55  55  55  55  55  00  00  07  00  40  00  00  80
2024-11-13 13:49:37,362 # 00000130  98  1C  00  20  70  1D  00  20  04  00  00  00  01  00  00  00
2024-11-13 13:49:37,368 # 00000140  01  55  55  55  55  55  55  55  7B  3B  3A  02  B8  0E  00  00
2024-11-13 13:49:37,375 # 00000150  85  00  2A  CF  00  00  00  00  20  1D  00  20  98  1D  00  20
2024-11-13 13:49:37,381 # 00000160  28  00  00  00  01  00  00  00  02  55  55  55  55  55  55  55
2024-11-13 13:49:37,387 # 00000170  60  00  00  00  00  18  3A  FF  FE  80  00  00  00  00  00  00
2024-11-13 13:49:37,394 # 00000180  64  19  E8  3F  8E  6B  4C  E6  FF  02  00  00  00  00  00  00
2024-11-13 13:49:37,400 # 00000190  00  00  00  00  00  00  00  02  E0  1D  00  20  D8  1D  00  20
2024-11-13 13:49:37,407 # 000001A0  08  00  00  00  01  00  00  00  FF  55  55  55  55  55  55  55
2024-11-13 13:49:37,413 # 000001B0  00  00  06  00  40  00  00  80  80  1D  00  20  F8  1D  00  20
2024-11-13 13:49:37,419 # 000001C0  01  00  00  00  01  00  00  00  01  55  55  55  55  55  55  55
2024-11-13 13:49:37,426 # 000001D0  41  00  00  00  30  0E  00  00  00  00  00  00  18  1E  00  20
2024-11-13 13:49:37,432 # 000001E0  10  00  00  00  01  00  00  00  00  55  55  55  55  55  55  55
2024-11-13 13:49:37,438 # 000001F0  01  02  66  19  E8  3F  8E  6B  4C  E7  00  00  00  00  00  00
2024-11-13 13:49:37,445 # 00000200  00  1E  00  20  40  1E  00  20  08  00  00  00  01  00  00  00
2024-11-13 13:49:37,451 # 00000210  03  55  55  55  55  55  55  55  85  00  2A  CD  00  00  00  00
2024-11-13 13:49:37,458 # 00000220  28  1E  00  20  60  1E  00  20  28  00  00  00  01  00  00  00
2024-11-13 13:49:37,464 # 00000230  02  55  55  55  55  55  55  55  60  00  00  00  00  18  3A  FF
2024-11-13 13:49:37,470 # 00000240  FE  80  00  00  00  00  00  00  64  19  E8  3F  8E  6B  4C  E7
2024-11-13 13:49:37,477 # 00000250  FF  02  00  00  00  00  00  00  00  00  00  00  00  00  00  02
2024-11-13 13:49:37,483 # 00000260  A8  1E  00  20  A0  1E  00  20  08  00  00  00  01  00  00  00
2024-11-13 13:49:37,490 # 00000270  FF  55  55  55  55  55  55  55  00  00  07  00  40  00  00  80
2024-11-13 13:49:37,496 # 00000280  48  1E  00  20  C0  1E  00  20  01  00  00  00  01  00  00  00
2024-11-13 13:49:37,502 # 00000290  01  55  55  55  55  55  55  55  41  00  00  00  68  0D  00  00
2024-11-13 13:49:37,509 # 000002A0  00  00  00  00  E0  1E  00  20  10  00  00  00  01  00  00  00
2024-11-13 13:49:37,515 # 000002B0  00  55  55  55  55  55  55  55  01  02  66  19  E8  3F  8E  6B
2024-11-13 13:49:37,522 # 000002C0  4C  E6  00  00  00  00  00  00  C8  1E  00  20  08  1F  00  20
2024-11-13 13:49:37,528 # 000002D0  08  00  00  00  01  00  00  00  03  55  55  55  55  55  55  55
2024-11-13 13:49:37,534 # 000002E0  85  00  2A  CF  00  00  00  00  F0  1E  00  20  28  1F  00  20
2024-11-13 13:49:37,541 # 000002F0  28  00  00  00  01  00  00  00  02  55  55  55  55  55  55  55
2024-11-13 13:49:37,547 # 00000300  60  00  00  00  00  18  3A  FF  FE  80  00  00  00  00  00  00
2024-11-13 13:49:37,553 # 00000310  64  19  E8  3F  8E  6B  4C  E6  FF  02  00  00  00  00  00  00
2024-11-13 13:49:37,560 # 00000320  00  00  00  00  00  00  00  02  70  1F  00  20  68  1F  00  20
2024-11-13 13:49:37,566 # 00000330  08  00  00  00  01  00  00  00  FF  55  55  55  55  55  55  55
2024-11-13 13:49:37,573 # 00000340  00  00  06  00  40  00  00  80  10  1F  00  20  88  1F  00  20
2024-11-13 13:49:37,579 # 00000350  01  00  00  00  01  00  00  00  01  55  55  55  55  55  55  55
2024-11-13 13:49:37,585 # 00000360  41  2B  00  20  E0  03  00  00  00  00  00  00  A8  1F  00  20
2024-11-13 13:49:37,592 # 00000370  10  00  00  00  01  00  00  00  00  55  55  55  55  55  55  55
2024-11-13 13:49:37,598 # 00000380  01  02  66  19  E8  3F  8E  6B  4C  E7  00  00  00  00  00  00
2024-11-13 13:49:37,605 # 00000390  90  1F  00  20  D0  1F  00  20  08  00  00  00  01  00  00  00
2024-11-13 13:49:37,611 # 000003A0  03  55  55  55  55  55  55  55  85  00  2A  CD  00  00  00  00
2024-11-13 13:49:37,617 # 000003B0  B8  1F  00  20  F0  1F  00  20  28  00  00  00  01  00  00  00
2024-11-13 13:49:37,624 # 000003C0  02  55  55  55  55  55  55  55  60  00  00  00  00  18  3A  FF
2024-11-13 13:49:37,630 # 000003D0  FE  80  00  00  00  00  00  00  64  19  E8  3F  8E  6B  4C  E7
2024-11-13 13:49:37,637 # 000003E0  FF  02  00  00  00  00  00  00  00  00  00  00  00  00  00  02
2024-11-13 13:49:37,643 # 000003F0  38  20  00  20  30  20  00  20  08  00  00  00  01  00  00  00
2024-11-13 13:49:37,649 # 00000400  FF  55  55  55  55  55  55  55  00  00  07  00  40  00  00  80
2024-11-13 13:49:37,656 # 00000410  D8  1F  00  20  50  20  00  20  01  00  00  00  01  00  00  00
2024-11-13 13:49:37,662 # 00000420  01  55  55  55  55  55  55  55  41  2B  00  20  18  03  00  00
2024-11-13 13:49:37,668 # 00000430  00  00  00  00  70  20  00  20  10  00  00  00  01  00  00  00
2024-11-13 13:49:37,675 # 00000440  00  55  55  55  55  55  55  55  01  02  66  19  E8  3F  8E  6B
2024-11-13 13:49:37,681 # 00000450  4C  E6  00  00  00  00  00  00  58  20  00  20  98  20  00  20
2024-11-13 13:49:37,688 # 00000460  08  00  00  00  01  00  00  00  03  55  55  55  55  55  55  55
2024-11-13 13:49:37,694 # 00000470  85  00  2A  CF  00  00  00  00  80  20  00  20  B8  20  00  20
2024-11-13 13:49:37,700 # 00000480  28  00  00  00  01  00  00  00  02  55  55  55  55  55  55  55
2024-11-13 13:49:37,707 # 00000490  60  00  00  00  00  18  3A  FF  FE  80  00  00  00  00  00  00
2024-11-13 13:49:37,713 # 000004A0  64  19  E8  3F  8E  6B  4C  E6  FF  02  00  00  00  00  00  00
2024-11-13 13:49:37,720 # 000004B0  00  00  00  00  00  00  00  02  00  21  00  20  F8  20  00  20
2024-11-13 13:49:37,726 # 000004C0  08  00  00  00  01  00  00  00  FF  55  55  55  55  55  55  55
2024-11-13 13:49:37,732 # 000004D0  00  00  06  00  40  00  00  80  A0  20  00  20  18  21  00  20
2024-11-13 13:49:37,739 # 000004E0  01  00  00  00  01  00  00  00  01  55  55  55  55  55  55  55
2024-11-13 13:49:37,745 # 000004F0  41  2B  00  20  50  02  00  00  00  00  00  00  38  21  00  20
2024-11-13 13:49:37,752 # 00000500  10  00  00  00  01  00  00  00  00  55  55  55  55  55  55  55
2024-11-13 13:49:37,758 # 00000510  01  02  66  19  E8  3F  8E  6B  4C  E7  00  00  00  00  00  00
2024-11-13 13:49:37,764 # 00000520  20  21  00  20  60  21  00  20  08  00  00  00  01  00  00  00
2024-11-13 13:49:37,771 # 00000530  03  55  55  55  55  55  55  55  85  00  2A  CD  00  00  00  00
2024-11-13 13:49:37,777 # 00000540  48  21  00  20  80  21  00  20  28  00  00  00  01  00  00  00
2024-11-13 13:49:37,784 # 00000550  02  55  55  55  55  55  55  55  60  00  00  00  00  18  3A  FF
2024-11-13 13:49:37,790 # 00000560  FE  80  00  00  00  00  00  00  64  19  E8  3F  8E  6B  4C  E7
2024-11-13 13:49:37,796 # 00000570  FF  02  00  00  00  00  00  00  00  00  00  00  00  00  00  02
2024-11-13 13:49:37,803 # 00000580  C8  21  00  20  C0  21  00  20  08  00  00  00  01  00  00  00
2024-11-13 13:49:37,809 # 00000590  FF  55  55  55  55  55  55  55  00  00  07  00  40  00  00  80
2024-11-13 13:49:37,815 # 000005A0  68  21  00  20  E0  21  00  20  01  00  00  00  01  00  00  00
2024-11-13 13:49:37,822 # 000005B0  01  55  55  55  55  55  55  55  41  2B  00  20  88  01  00  00
2024-11-13 13:49:37,828 # 000005C0  00  00  00  00  00  22  00  20  10  00  00  00  01  00  00  00
2024-11-13 13:49:37,835 # 000005D0  00  55  55  55  55  55  55  55  01  02  66  19  E8  3F  8E  6B
2024-11-13 13:49:37,841 # 000005E0  4C  E6  00  00  00  00  00  00  E8  21  00  20  28  22  00  20
2024-11-13 13:49:37,847 # 000005F0  08  00  00  00  01  00  00  00  03  55  55  55  55  55  55  55
2024-11-13 13:49:37,854 # 00000600  85  00  2A  CF  00  00  00  00  10  22  00  20  48  22  00  20
2024-11-13 13:49:37,860 # 00000610  28  00  00  00  01  00  00  00  02  55  55  55  55  55  55  55
2024-11-13 13:49:37,867 # 00000620  60  00  00  00  00  18  3A  FF  FE  80  00  00  00  00  00  00
2024-11-13 13:49:37,873 # 00000630  64  19  E8  3F  8E  6B  4C  E6  FF  02  00  00  00  00  00  00
2024-11-13 13:49:37,879 # 00000640  00  00  00  00  00  00  00  02  90  22  00  20  88  22  00  20
2024-11-13 13:49:37,886 # 00000650  08  00  00  00  01  00  00  00  FF  55  55  55  55  55  55  55
2024-11-13 13:49:37,892 # 00000660  00  00  06  00  40  00  00  80  30  22  00  20  A8  22  00  20
2024-11-13 13:49:37,899 # 00000670  01  00  00  00  01  00  00  00  01  55  55  55  55  55  55  55
2024-11-13 13:49:37,905 # 00000680  41  2B  00  20  C0  00  00  00  00  00  00  00  C8  22  00  20
2024-11-13 13:49:37,911 # 00000690  10  00  00  00  01  00  00  00  00  55  55  55  55  55  55  55
2024-11-13 13:49:37,918 # 000006A0  01  02  66  19  E8  3F  8E  6B  4C  E7  00  00  00  00  00  00
2024-11-13 13:49:37,924 # 000006B0  B0  22  00  20  F0  22  00  20  08  00  00  00  01  00  00  00
2024-11-13 13:49:37,931 # 000006C0  03  55  55  55  55  55  55  55  85  00  2A  CD  00  00  00  00
2024-11-13 13:49:37,937 # 000006D0  D8  22  00  20  10  23  00  20  28  00  00  00  01  00  00  00
2024-11-13 13:49:37,943 # 000006E0  02  55  55  55  55  55  55  55  60  00  00  00  00  18  3A  FF
2024-11-13 13:49:37,950 # 000006F0  FE  80  00  00  00  00  00  00  64  19  E8  3F  8E  6B  4C  E7
2024-11-13 13:49:37,956 # 00000700  FF  02  00  00  00  00  00  00  00  00  00  00  00  00  00  02
2024-11-13 13:49:37,963 # 00000710  D8  2B  00  20  50  23  00  20  08  00  00  00  01  00  00  00
2024-11-13 13:49:37,969 # 00000720  FF  55  55  55  55  55  55  55  00  00  07  00  40  00  00  80
2024-11-13 13:49:37,972 # 00000730  41  2B  00  20  10  00  00  00
2024-11-13 13:49:37,977 # ~ unused: 0x20002360 (next: 0x20002bf0, size:    8) ~
2024-11-13 13:49:37,982 # =========== chunk   1 (0x20002368 size: 2184) ===========
2024-11-13 13:49:37,989 # 00000000  88  23  00  20  80  23  00  20  08  00  00  00  01  00  00  00
2024-11-13 13:49:37,995 # 00000010  FF  55  55  55  55  55  55  55  00  00  06  00  50  00  00  80
2024-11-13 13:49:38,001 # 00000020  00  00  00  00  A0  23  00  20  65  00  00  00  01  00  00  00
2024-11-13 13:49:38,008 # 00000030  01  55  55  55  55  55  55  55  C4  30  00  01  41  60  00  00
2024-11-13 13:49:38,014 # 00000040  00  04  08  3A  40  FE  80  00  00  00  00  00  00  64  19  E8
2024-11-13 13:49:38,021 # 00000050  3F  8E  6B  4C  E6  FF  02  00  00  00  00  00  00  00  00  00
2024-11-13 13:49:38,027 # 00000060  00  00  00  00  23  80  00  87  1D  1A  E3  00  00  87  69  28
2024-11-13 13:49:38,033 # 00000070  00  00  01  02  03  04  05  06  07  08  09  0A  0B  0C  0D  0E
2024-11-13 13:49:38,040 # 00000080  0F  10  11  12  13  14  15  16  17  18  19  1A  1B  1C  1D  1E
2024-11-13 13:49:38,046 # 00000090  1F  20  21  22  23  24  25  26  27  28  29  2A  2B  55  55  55
2024-11-13 13:49:38,053 # 000000A0  28  24  00  20  20  24  00  20  08  00  00  00  01  00  00  00
2024-11-13 13:49:38,059 # 000000B0  FF  55  55  55  55  55  55  55  00  00  06  00  50  00  00  80
2024-11-13 13:49:38,065 # 000000C0  00  00  00  00  40  24  00  20  65  00  00  00  01  00  00  00
2024-11-13 13:49:38,072 # 000000D0  01  55  55  55  55  55  55  55  E4  30  00  01  0C  2C  2D  2E
2024-11-13 13:49:38,078 # 000000E0  2F  30  31  32  33  34  35  36  37  38  39  3A  3B  3C  3D  3E
2024-11-13 13:49:38,085 # 000000F0  3F  40  41  42  43  44  45  46  47  48  49  4A  4B  4C  4D  4E
2024-11-13 13:49:38,091 # 00000100  4F  50  51  52  53  54  55  56  57  58  59  5A  5B  5C  5D  5E
2024-11-13 13:49:38,097 # 00000110  5F  60  61  62  63  64  65  66  67  68  69  6A  6B  6C  6D  6E
2024-11-13 13:49:38,104 # 00000120  6F  70  71  72  73  74  75  76  77  78  79  7A  7B  7C  7D  7E
2024-11-13 13:49:38,110 # 00000130  7F  80  81  82  83  84  85  86  87  88  89  8A  8B  55  55  55
2024-11-13 13:49:38,116 # 00000140  C8  24  00  20  C0  24  00  20  08  00  00  00  01  00  00  00
2024-11-13 13:49:38,123 # 00000150  FF  55  55  55  55  55  55  55  00  00  06  00  50  00  00  80
2024-11-13 13:49:38,129 # 00000160  00  00  00  00  E0  24  00  20  65  00  00  00  01  00  00  00
2024-11-13 13:49:38,136 # 00000170  01  55  55  55  55  55  55  55  E4  30  00  01  18  8C  8D  8E
2024-11-13 13:49:38,142 # 00000180  8F  90  91  92  93  94  95  96  97  98  99  9A  9B  9C  9D  9E
2024-11-13 13:49:38,148 # 00000190  9F  A0  A1  A2  A3  A4  A5  A6  A7  A8  A9  AA  AB  AC  AD  AE
2024-11-13 13:49:38,155 # 000001A0  AF  B0  B1  B2  B3  B4  B5  B6  B7  B8  B9  BA  BB  BC  BD  BE
2024-11-13 13:49:38,161 # 000001B0  BF  C0  C1  C2  C3  C4  C5  C6  C7  C8  C9  CA  CB  CC  CD  CE
2024-11-13 13:49:38,168 # 000001C0  CF  D0  D1  D2  D3  D4  D5  D6  D7  D8  D9  DA  DB  DC  DD  DE
2024-11-13 13:49:38,174 # 000001D0  DF  E0  E1  E2  E3  E4  E5  E6  E7  E8  E9  EA  EB  55  55  55
2024-11-13 13:49:38,180 # 000001E0  68  25  00  20  60  25  00  20  08  00  00  00  01  00  00  00
2024-11-13 13:49:38,187 # 000001F0  FF  55  55  55  55  55  55  55  00  00  06  00  50  00  00  80
2024-11-13 13:49:38,193 # 00000200  00  00  00  00  80  25  00  20  65  00  00  00  01  00  00  00
2024-11-13 13:49:38,200 # 00000210  01  55  55  55  55  55  55  55  E4  30  00  01  24  EC  ED  EE
2024-11-13 13:49:38,206 # 00000220  EF  F0  F1  F2  F3  F4  F5  F6  F7  F8  F9  FA  FB  FC  FD  FE
2024-11-13 13:49:38,212 # 00000230  FF  00  01  02  03  04  05  06  07  08  09  0A  0B  0C  0D  0E
2024-11-13 13:49:38,219 # 00000240  0F  10  11  12  13  14  15  16  17  18  19  1A  1B  1C  1D  1E
2024-11-13 13:49:38,225 # 00000250  1F  20  21  22  23  24  25  26  27  28  29  2A  2B  2C  2D  2E
2024-11-13 13:49:38,231 # 00000260  2F  30  31  32  33  34  35  36  37  38  39  3A  3B  3C  3D  3E
2024-11-13 13:49:38,238 # 00000270  3F  40  41  42  43  44  45  46  47  48  49  4A  4B  55  55  55
2024-11-13 13:49:38,244 # 00000280  08  26  00  20  00  26  00  20  08  00  00  00  01  00  00  00
2024-11-13 13:49:38,251 # 00000290  FF  55  55  55  55  55  55  55  00  00  06  00  50  00  00  80
2024-11-13 13:49:38,257 # 000002A0  00  00  00  00  20  26  00  20  65  00  00  00  01  00  00  00
2024-11-13 13:49:38,263 # 000002B0  01  55  55  55  55  55  55  55  E4  30  00  01  30  4C  4D  4E
2024-11-13 13:49:38,270 # 000002C0  4F  50  51  52  53  54  55  56  57  58  59  5A  5B  5C  5D  5E
2024-11-13 13:49:38,276 # 000002D0  5F  60  61  62  63  64  65  66  67  68  69  6A  6B  6C  6D  6E
2024-11-13 13:49:38,283 # 000002E0  6F  70  71  72  73  74  75  76  77  78  79  7A  7B  7C  7D  7E
2024-11-13 13:49:38,289 # 000002F0  7F  80  81  82  83  84  85  86  87  88  89  8A  8B  8C  8D  8E
2024-11-13 13:49:38,295 # 00000300  8F  90  91  92  93  94  95  96  97  98  99  9A  9B  9C  9D  9E
2024-11-13 13:49:38,302 # 00000310  9F  A0  A1  A2  A3  A4  A5  A6  A7  A8  A9  AA  AB  55  55  55
2024-11-13 13:49:38,308 # 00000320  A8  26  00  20  A0  26  00  20  08  00  00  00  01  00  00  00
2024-11-13 13:49:38,315 # 00000330  FF  55  55  55  55  55  55  55  00  00  06  00  50  00  00  80
2024-11-13 13:49:38,321 # 00000340  00  00  00  00  C0  26  00  20  65  00  00  00  01  00  00  00
2024-11-13 13:49:38,327 # 00000350  01  55  55  55  55  55  55  55  E4  30  00  01  3C  AC  AD  AE
2024-11-13 13:49:38,334 # 00000360  AF  B0  B1  B2  B3  B4  B5  B6  B7  B8  B9  BA  BB  BC  BD  BE
2024-11-13 13:49:38,340 # 00000370  BF  C0  C1  C2  C3  C4  C5  C6  C7  C8  C9  CA  CB  CC  CD  CE
2024-11-13 13:49:38,347 # 00000380  CF  D0  D1  D2  D3  D4  D5  D6  D7  D8  D9  DA  DB  DC  DD  DE
2024-11-13 13:49:38,353 # 00000390  DF  E0  E1  E2  E3  E4  E5  E6  E7  E8  E9  EA  EB  EC  ED  EE
2024-11-13 13:49:38,359 # 000003A0  EF  F0  F1  F2  F3  F4  F5  F6  F7  F8  F9  FA  FB  FC  FD  FE
2024-11-13 13:49:38,366 # 000003B0  FF  00  01  02  03  04  05  06  07  08  09  0A  0B  55  55  55
2024-11-13 13:49:38,372 # 000003C0  48  27  00  20  40  27  00  20  08  00  00  00  01  00  00  00
2024-11-13 13:49:38,378 # 000003D0  FF  55  55  55  55  55  55  55  00  00  06  00  50  00  00  80
2024-11-13 13:49:38,385 # 000003E0  00  00  00  00  60  27  00  20  65  00  00  00  01  00  00  00
2024-11-13 13:49:38,391 # 000003F0  01  55  55  55  55  55  55  55  E4  30  00  01  48  0C  0D  0E
2024-11-13 13:49:38,398 # 00000400  0F  10  11  12  13  14  15  16  17  18  19  1A  1B  1C  1D  1E
2024-11-13 13:49:38,404 # 00000410  1F  20  21  22  23  24  25  26  27  28  29  2A  2B  2C  2D  2E
2024-11-13 13:49:38,410 # 00000420  2F  30  31  32  33  34  35  36  37  38  39  3A  3B  3C  3D  3E
2024-11-13 13:49:38,417 # 00000430  3F  40  41  42  43  44  45  46  47  48  49  4A  4B  4C  4D  4E
2024-11-13 13:49:38,423 # 00000440  4F  50  51  52  53  54  55  56  57  58  59  5A  5B  5C  5D  5E
2024-11-13 13:49:38,430 # 00000450  5F  60  61  62  63  64  65  66  67  68  69  6A  6B  55  55  55
2024-11-13 13:49:38,436 # 00000460  E8  27  00  20  E0  27  00  20  08  00  00  00  01  00  00  00
2024-11-13 13:49:38,442 # 00000470  FF  55  55  55  55  55  55  55  00  00  06  00  50  00  00  80
2024-11-13 13:49:38,449 # 00000480  00  00  00  00  00  28  00  20  65  00  00  00  01  00  00  00
2024-11-13 13:49:38,455 # 00000490  01  55  55  55  55  55  55  55  E4  30  00  01  54  6C  6D  6E
2024-11-13 13:49:38,462 # 000004A0  6F  70  71  72  73  74  75  76  77  78  79  7A  7B  7C  7D  7E
2024-11-13 13:49:38,468 # 000004B0  7F  80  81  82  83  84  85  86  87  88  89  8A  8B  8C  8D  8E
2024-11-13 13:49:38,474 # 000004C0  8F  90  91  92  93  94  95  96  97  98  99  9A  9B  9C  9D  9E
2024-11-13 13:49:38,481 # 000004D0  9F  A0  A1  A2  A3  A4  A5  A6  A7  A8  A9  AA  AB  AC  AD  AE
2024-11-13 13:49:38,487 # 000004E0  AF  B0  B1  B2  B3  B4  B5  B6  B7  B8  B9  BA  BB  BC  BD  BE
2024-11-13 13:49:38,493 # 000004F0  BF  C0  C1  C2  C3  C4  C5  C6  C7  C8  C9  CA  CB  55  55  55
2024-11-13 13:49:38,500 # 00000500  88  28  00  20  80  28  00  20  08  00  00  00  01  00  00  00
2024-11-13 13:49:38,506 # 00000510  FF  55  55  55  55  55  55  55  00  00  06  00  50  00  00  80
2024-11-13 13:49:38,513 # 00000520  00  00  00  00  A0  28  00  20  65  00  00  00  01  00  00  00
2024-11-13 13:49:38,519 # 00000530  01  55  55  55  55  55  55  55  E4  30  00  01  60  CC  CD  CE
2024-11-13 13:49:38,525 # 00000540  CF  D0  D1  D2  D3  D4  D5  D6  D7  D8  D9  DA  DB  DC  DD  DE
2024-11-13 13:49:38,532 # 00000550  DF  E0  E1  E2  E3  E4  E5  E6  E7  E8  E9  EA  EB  EC  ED  EE
2024-11-13 13:49:38,538 # 00000560  EF  F0  F1  F2  F3  F4  F5  F6  F7  F8  F9  FA  FB  FC  FD  FE
2024-11-13 13:49:38,545 # 00000570  FF  00  01  02  03  04  05  06  07  08  09  0A  0B  0C  0D  0E
2024-11-13 13:49:38,551 # 00000580  0F  10  11  12  13  14  15  16  17  18  19  1A  1B  1C  1D  1E
2024-11-13 13:49:38,557 # 00000590  1F  20  21  22  23  24  25  26  27  28  29  2A  2B  55  55  55
2024-11-13 13:49:38,564 # 000005A0  28  29  00  20  20  29  00  20  08  00  00  00  01  00  00  00
2024-11-13 13:49:38,570 # 000005B0  FF  55  55  55  55  55  55  55  00  00  06  00  50  00  00  80
2024-11-13 13:49:38,577 # 000005C0  00  00  00  00  40  29  00  20  65  00  00  00  01  00  00  00
2024-11-13 13:49:38,583 # 000005D0  01  55  55  55  55  55  55  55  E4  30  00  01  6C  2C  2D  2E
2024-11-13 13:49:38,589 # 000005E0  2F  30  31  32  33  34  35  36  37  38  39  3A  3B  3C  3D  3E
2024-11-13 13:49:38,596 # 000005F0  3F  40  41  42  43  44  45  46  47  48  49  4A  4B  4C  4D  4E
2024-11-13 13:49:38,602 # 00000600  4F  50  51  52  53  54  55  56  57  58  59  5A  5B  5C  5D  5E
2024-11-13 13:49:38,609 # 00000610  5F  60  61  62  63  64  65  66  67  68  69  6A  6B  6C  6D  6E
2024-11-13 13:49:38,615 # 00000620  6F  70  71  72  73  74  75  76  77  78  79  7A  7B  7C  7D  7E
2024-11-13 13:49:38,621 # 00000630  7F  80  81  82  83  84  85  86  87  88  89  8A  8B  55  55  55
2024-11-13 13:49:38,628 # 00000640  C8  29  00  20  C0  29  00  20  08  00  00  00  01  00  00  00
2024-11-13 13:49:38,634 # 00000650  FF  55  55  55  55  55  55  55  00  00  06  00  50  00  00  80
2024-11-13 13:49:38,640 # 00000660  00  00  00  00  E0  29  00  20  65  00  00  00  01  00  00  00
2024-11-13 13:49:38,647 # 00000670  01  55  55  55  55  55  55  55  E4  30  00  01  78  8C  8D  8E
2024-11-13 13:49:38,653 # 00000680  8F  90  91  92  93  94  95  96  97  98  99  9A  9B  9C  9D  9E
2024-11-13 13:49:38,660 # 00000690  9F  A0  A1  A2  A3  A4  A5  A6  A7  A8  A9  AA  AB  AC  AD  AE
2024-11-13 13:49:38,666 # 000006A0  AF  B0  B1  B2  B3  B4  B5  B6  B7  B8  B9  BA  BB  BC  BD  BE
2024-11-13 13:49:38,672 # 000006B0  BF  C0  C1  C2  C3  C4  C5  C6  C7  C8  C9  CA  CB  CC  CD  CE
2024-11-13 13:49:38,679 # 000006C0  CF  D0  D1  D2  D3  D4  D5  D6  D7  D8  D9  DA  DB  DC  DD  DE
2024-11-13 13:49:38,685 # 000006D0  DF  E0  E1  E2  E3  E4  E5  E6  E7  E8  E9  EA  EB  55  55  55
2024-11-13 13:49:38,692 # 000006E0  68  2A  00  20  60  2A  00  20  08  00  00  00  01  00  00  00
2024-11-13 13:49:38,698 # 000006F0  FF  55  55  55  55  55  55  55  00  00  06  00  40  00  00  80
2024-11-13 13:49:38,704 # 00000700  00  00  00  00  80  2A  00  20  15  00  00  00  01  00  00  00
2024-11-13 13:49:38,711 # 00000710  01  55  55  55  55  55  55  55  E4  30  00  01  84  EC  ED  EE
2024-11-13 13:49:38,717 # 00000720  EF  F0  F1  F2  F3  F4  F5  F6  F7  F8  F9  FA  FB  55  55  55
2024-11-13 13:49:38,724 # 00000730  B8  2A  00  20  B0  2A  00  20  08  00  00  00  01  00  00  00
2024-11-13 13:49:38,730 # 00000740  FF  55  55  55  55  55  55  55  00  00  06  00  50  00  00  80
2024-11-13 13:49:38,736 # 00000750  00  00  00  00  D0  2A  00  20  65  00  00  00  01  00  00  00
2024-11-13 13:49:38,743 # 00000760  01  55  55  55  55  55  55  55  C4  30  00  02  41  60  00  00
2024-11-13 13:49:38,749 # 00000770  00  04  08  3A  40  FE  80  00  00  00  00  00  00  64  19  E8
2024-11-13 13:49:38,756 # 00000780  3F  8E  6B  4C  E6  FF  02  00  00  00  00  00  00  00  00  00
2024-11-13 13:49:38,762 # 00000790  00  00  00  00  23  80  00  2C  DA  1A  E3  00  01  D2  AB  37
2024-11-13 13:49:38,768 # 000007A0  00  00  01  02  03  04  05  06  07  08  09  0A  0B  0C  0D  0E
2024-11-13 13:49:38,775 # 000007B0  0F  10  11  12  13  14  15  16  17  18  19  1A  1B  1C  1D  1E
2024-11-13 13:49:38,781 # 000007C0  1F  20  21  22  23  24  25  26  27  28  29  2A  2B  55  55  55
2024-11-13 13:49:38,787 # 000007D0  58  2B  00  20  50  2B  00  20  08  00  00  00  01  00  00  00
2024-11-13 13:49:38,794 # 000007E0  FF  55  55  55  55  55  55  55  00  00  06  00  50  00  00  80
2024-11-13 13:49:38,800 # 000007F0  00  00  00  00  70  2B  00  20  65  00  00  00  01  00  00  00
2024-11-13 13:49:38,807 # 00000800  01  55  55  55  55  55  55  55  E4  30  00  02  0C  2C  2D  2E
2024-11-13 13:49:38,813 # 00000810  2F  30  31  32  33  34  35  36  37  38  39  3A  3B  3C  3D  3E
2024-11-13 13:49:38,819 # 00000820  3F  40  41  42  43  44  45  46  47  48  49  4A  4B  4C  4D  4E
2024-11-13 13:49:38,826 # 00000830  4F  50  51  52  53  54  55  56  57  58  59  5A  5B  5C  5D  5E
2024-11-13 13:49:38,832 # 00000840  5F  60  61  62  63  64  65  66  67  68  69  6A  6B  6C  6D  6E
2024-11-13 13:49:38,839 # 00000850  6F  70  71  72  73  74  75  76  77  78  79  7A  7B  7C  7D  7E
2024-11-13 13:49:38,845 # 00000860  7F  80  81  82  83  84  85  86  87  88  89  8A  8B  55  55  55
2024-11-13 13:49:38,851 # 00000870  F8  22  00  20  58  23  00  20  01  00  00  00  01  00  00  00
2024-11-13 13:49:38,855 # 00000880  01  55  55  55  55  55  55  55
2024-11-13 13:49:38,859 # ~ unused: 0x20002bf0 (next: (nil), size:   56) ~

this PR

2024-11-13 13:47:18,707 # ping -c 10 -s 1024 ff02::23%6
2024-11-13 13:47:28,707 # 
2024-11-13 13:47:28,710 # --- ff02::23%6 PING statistics ---
2024-11-13 13:47:28,715 # 10 packets transmitted, 0 packets received, 100% packet loss

pktbuf is empty

2024-11-13 13:47:40,001 # packet buffer: first byte: 0x20001c28, last byte: 0x20002c28 (size: 4096)
2024-11-13 13:47:40,004 #   position of last byte used: 3024
2024-11-13 13:47:40,008 # ~ unused: 0x20001c28 (next: (nil), size: 4096) ~

Issues/PRs references

#11263 (comment)

@benpicco benpicco requested a review from maribu November 13, 2024 12:50
@github-actions github-actions bot added Area: network Area: Networking Area: sys Area: System labels Nov 13, 2024
@benpicco benpicco added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) labels Nov 13, 2024
@benpicco
Copy link
Contributor Author

Hmm not so fast, looks like we are getting a double free now 😕

[0x20009048] mismatch at offset 12/24 (ignoring 8 initial bytes that were repurposed)
00000000  00  00  00  00  90  0F  00  00  55  55  55  55  54  55  55  55
00000010  55  55  55  55  55  55  55  55
sys/net/gnrc/pktbuf_static/gnrc_pktbuf_static.c:435 => FAILED ASSERTION.

@maribu
Copy link
Member

maribu commented Nov 13, 2024

So +1 +1 -1 -1 evaluates to 1 and +1 -1 evaluates to -1? Sounds a lot like Pippi Langstrumpf math to me 😅

@miri64
Copy link
Member

miri64 commented Nov 13, 2024

Run a driver that makes use of both netdev_new_api and gnrc_netif_pktq (e.g. at86rf215):

But also test the other combinations so you do not introduce regressions there ;-).

@benpicco
Copy link
Contributor Author

I think I know what was going on here: gnrc_pktbuf_hold() increments the user count of all snips on the pkg, then gnrc_netif_raw decrements the count on the first snip, bringing that to 1 while the other snips are still at 2. _tx_done() then decremented the count again, dropping the first snip to 0 and leaving the rest at 1, or with with first patch only brought the first snip to -1.

@riot-ci
Copy link

riot-ci commented Nov 13, 2024

Murdock results

✔️ PASSED

1629a6a drivers/at86rf215: properly implement netdev_new

Success Failures Total Runtime
10251 0 10251 17m:18s

Artifacts

@github-actions github-actions bot added the Area: drivers Area: Device drivers label Nov 13, 2024
@benpicco benpicco added the Process: needs backport Integration Process: The PR is required to be backported to a release or feature branch label Nov 13, 2024
@benpicco
Copy link
Contributor Author

But also test the other combinations so you do not introduce regressions there ;-).

Since all the new addions are now the else case of gnrc_netif_netdev_legacy_api() I think we're good here 😉

I'm not saying there are no leaks when combining !netdev_new with netdev_new, but those would be unrelated to the fixes for the netdev_new-only case - I'll give that a try tomorrow.

miri64
miri64 previously requested changes Nov 13, 2024
Copy link
Member

@miri64 miri64 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure this works. I am not sure if just skipping pkt (without releasing it) now generates a leak.

@miri64 miri64 dismissed their stale review November 14, 2024 08:39

Was addressed

@benpicco benpicco force-pushed the gnrc_netif_netdev_new_api-leak branch from f238c84 to 8318a48 Compare November 14, 2024 10:50
@benpicco
Copy link
Contributor Author

A border router (at86rf215/slip) managed to survive the night with those changes and periodic traffic 🎉

@benpicco benpicco force-pushed the gnrc_netif_netdev_new_api-leak branch from 8318a48 to 1629a6a Compare November 14, 2024 10:58
@benpicco benpicco added this pull request to the merge queue Nov 14, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Nov 15, 2024
@maribu maribu added this pull request to the merge queue Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: drivers Area: Device drivers Area: network Area: Networking Area: sys Area: System CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Process: needs backport Integration Process: The PR is required to be backported to a release or feature branch Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants